﻿//我的
class Solution {
public:
	int getSum(int a, int b) {
		int num1 = a ^ b, num2 = (a & b) << 1;//非进位相加

		while (num2 != 0) {
			a = num1, b = num2;
			num1 = a ^ b;//非进位相加
			num2 = (a & b) << 1;//只有2数相加的进位
		}

		return num1;
	}
};

//答案
class Solution
{
public:
	int getSum(int a, int b)
	{
		while (b != 0)
		{
			int x = a ^ b; // 先算出⽆进位相加的结果
			unsigned int carry = (unsigned int)(a & b) << 1; // 算出进位
			a = x;
			b = carry;
		}
		return a;
	}
};